package com.rimi.service.impl;

import com.rimi.bean.User;
import com.rimi.mapper.UserMapper;
import com.rimi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User loginByUsername(User user) {
        if ("".equals(user.getPassword()) || "".equals(user.getUsername())){
            return null;
        }
        return userMapper.selectUserByUsernameAndPassword(user);
    }

    @Override
    public User loginByEmail(User user) {
        if ("".equals(user.getPassword()) || "".equals(user.getEmail())){
            return null;
        }
        return userMapper.selectUserByEmailAndPassword(user);
    }

    @Override
    public User loginByPhone(User user) {
        if ("".equals(user.getPassword()) || "".equals(user.getPhone())){
            return null;
        }
        return userMapper.selectUserByPhoneAndPassword(user);
    }
}
